#!/usr/bin/bash

dwm-msg --ignore-reply subscribe tag_change_event |
  jq --unbuffered '.tag_change_event.new_state.selected' |
  while IFS=$'\n' read -r selected_tags; do
      tags=$(dwm-msg get_tags | jq ".[] | select(.bit_mask == $selected_tags)" | jq '.["name"]' | awk '{gsub(/"/,"",$1); print $1}')
    notify-send -t 1000 "$tags"
  done

